package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo4 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection();) {
            Statement statement = connection.createStatement();//创建执行sql语句的对象

            String sql = "delete from user "+"where id=1";//删除id为1的数据

            int num = statement.executeUpdate(sql);//返回受影响的行数
            System.out.println(num > 0 ? "删除成功" : "删除失败");
        } catch (SQLException e) {
           e.printStackTrace();
        }
    }
}
